package a02_Thread;

/**
 * @Author quan
 * @Description Thread的常见属性
 * @Date 2023/4/28 11:53
 */
public class Demo3_ThreadAttribute {
    public static void main(String[] args) {
        Thread t = new Thread(()->{
            while (true){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        },"线程名叫孙悟空");
        t.start();
        //打印Thread中的各种属性
        System.out.println("线程ID"+ t.getId());
        System.out.println("线程名"+t.getName());
        System.out.println("线程状态"+t.getState());
        System.out.println("线程优先级"+t.getPriority());
        System.out.println("线程是否后台"+t.isDaemon());
        System.out.println("线程是否存活"+t.isAlive());
        System.out.println("线程是否中断"+t.isInterrupted());
    }
}
